//
//  ReadyViewController.m
//  NewGame
//
//  Created by wwj on 15/10/12.
//  Copyright © 2015年 wwj. All rights reserved.
//

#import "ReadyViewController.h"
#import "ReadyTitleView.h"
#import "ReadyScoreView.h"
#import "StageModel.h"
#import "StageBaseViewController.h"

@interface ReadyViewController ()
@property (weak, nonatomic) IBOutlet UILabel *stageNo;
@property (weak, nonatomic) IBOutlet UILabel *stageIntro;
@property (weak, nonatomic) IBOutlet UIImageView *stageIcon;
@property (weak ,nonatomic) IBOutlet ReadyScoreView *readScoreView;

@end

@implementation ReadyViewController

-(void)setStageModel:(StageModel *)stageModel{
    _stageModel = stageModel;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _stageNo.text = [NSString stringWithFormat:@"Stage %d", _stageModel.no];
    _stageIntro.text = [_stageModel.intro stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"];
    _stageIcon.image = [UIImage imageNamed:_stageModel.icon];
    
    //设置过度页面
    ReadyTitleView *readyTitleView = [ReadyTitleView readyTitleView];
    readyTitleView.stageModel = _stageModel;
    [self.view addSubview:readyTitleView];
    
    readyTitleView.finishBlock = ^{
        //设置分数
        _readScoreView.stageModel = _stageModel;
    };
    
}

#pragma  -mark 开始游戏
- (IBAction)play {
    NSString *className =@"";
    if (_stageModel.no < 10) {
        className = [NSString stringWithFormat:@"Stage0%dViewController", _stageModel.no];
    }else{
        className = [NSString stringWithFormat:@"Stage%dViewController", _stageModel.no];
    }
    
    Class class = NSClassFromString(className);
    StageBaseViewController *vc = [[class alloc] init];
    vc.stageModel = _stageModel;
    [self.navigationController pushViewController:vc animated:YES];
    
}

#pragma -mark 返回
- (IBAction)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

@end
